from typing import TypedDict, Optional, List


# 基础 TypedDict
class UserInfo(TypedDict):
    name: str
    age: int
    email: str
    is_active: bool


# 使用示例
user: UserInfo = {
    "name": 44,
    "age": "25",
    "email": "zhangsan@example.com",
    "is_active": True,
}


# 嵌套 TypedDict
class Address(TypedDict):
    street: str
    city: str
    postal_code: str


class DetailedUser(TypedDict):
    user: UserInfo
    address: Address
    tags: List[str]


# 可选字段
class UserProfile(TypedDict, total=False):
    name: str
    age: int
    bio: Optional[str]  # 可选字段
    avatar: Optional[str]


""" 
interface User
{username:String}

let user:User """
